var rightMenuClock;
;(function($){
	$.guest_xsxm = $.guest_xsxm || {}
	$.fn.guest_xsxm = function(opts){
		var el = this;
		var opt = {
			xsxm_jdh_array:[],
			brzd_array:[],
			brzd_json:{},
			pageTh:"",
			multiCheck:"",				//多选 yes or no
			loadcomplete:function(){},		//加载完成回调
			dblClickBack : function(){},
			freshBack : function(){},
			clickBack:function(){},
		}
		var param = $.extend(opt,opts);
		var app = new App(el,param);
		$.guest_xsxm = $.extend($.guest_xsxm,app);
	}
	
	var App = function(el,param){
		this.el = el;
		this.param = param;
		this.initHtml();
		this.bindEvent();
		
//		if(param.pageTh!=""){
//			$(".xsxmTh_box[data-th='"+param.pageTh+"']").find(".rightXsxmTitle ").trigger("click")
//		}
		if(param.pageTh!=""){
			if(param.multiCheck=="yes"){
				$(".xsxmTh_box[data-th='"+param.pageTh+"']").find(".rightXsxmTitle").trigger("click")
			}else{
				var _this = $(".xsxmTh_box[data-th='"+param.pageTh+"']").find(".rightXsxmTitle ");
				$(_this).parent("div").parent("div").find(".rightXsxmTitle").removeClass("active")
//				$(_this).parent("div").parent("div").find(".rightXsxmTitle").find(".line3 .ifCheck,.multiSelBox").remove()
				$(_this).parent("div").parent("div").find(".rightXsxmTitle").find(".line3 .ifCheck,.ifCheckOut").remove()
				var html = '<div class="ifCheck" style="float:left;margin-right:3px;"><i class="fa fa-check" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
				$(_this).find(".line3").prepend(html)
//				var html_box = '<div class="multiSelBox"  style="width: 45px;height:45px;left:-23px;bottom:-23px;position:absolute;-webkit-transform: rotate(45deg);border: 1px solid #59d245;background: white;"></div>';
//				$(_this).find(".line3").append(html_box)
				var html1 = '<div class="ifCheckOut" style="float:left;margin-right:3px;"><i class="fa fa-sign-out" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
				$(_this).find(".line3").append(html1)
				$(_this).addClass("active")
			}
		}
		
		param.loadcomplete();
		
		this.retrievePayable();
	}
	
	App.prototype = {
		bindEvent : function(){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			el.find(".right_xsxm_box[data-sort='0']").unbind("dblclick").dblclick(function(){
				var json = JSON.parse(decodeURIComponent($(this).attr("data-mess")))
				param.dblClickBack(json);
			})
			
			if(param.multiCheck=="yes"){
				
				el.find(".right_xsxm_box[data-sort='0']").unbind("click").click(function(){
					var color = "#59d245"
					if( $(this).attr("data-th") != $("#pageTh").text() ){
						color = "#59d245"
					}
					
					if($(this).hasClass("active")){
						$(this).removeClass("active")
					}else{
						$(this).addClass("active")
					}
					if( $(this).parent("div").find(".right_xsxm_box.active[data-sort='0']").size()>0 && !$(this).parent("div").parent("div").find(".rightXsxmTitle").hasClass("active") ){
						$(this).parent("div").parent("div").find(".rightXsxmTitle").addClass("active")
						var html = '<div class="ifCheck" style="float:left;margin-right:3px;"><i class="fa fa-check" style="zoom: 95%;color:'+color+'" aria-hidden="true"></i></div>'
						$(this).parent("div").parent("div").find(".rightXsxmTitle").find(".line3").prepend(html)
					}
					if(0 == $(this).parent("div").find(".right_xsxm_box.active[data-sort='0']").size()){
						if(param.pageTh!="" && $(this).parent("div").parent("div").attr("data-th")!=param.pageTh){
							$(this).parent("div").parent("div").find(".rightXsxmTitle").removeClass("active")
							$(this).parent("div").parent("div").find(".rightXsxmTitle").find(".line3 .ifCheck").remove()
						}
						
					}
					t.retrievePayable();
				})
				
				el.find(".rightXsxmTitle").unbind("click").click(function(){
					var color = "#59d245"
					var html_box = '';
//					if( $(this).parent("div").attr("data-th") == $("#pageTh").text() ){
//						html_box =	'<div class="multiSelBox"  style="width: 45px;height:45px;left:-23px;bottom:-23px;position:absolute;-webkit-transform: rotate(45deg);border: 1px solid #59d245;background: white;"></div>';
//					}
					
					if($(this).hasClass("active")){
						if($(this).parent("div").find(".right_xsxm_box[data-sort='0']").size() == $(this).parent("div").find(".right_xsxm_box.active[data-sort='0']").size()){
							$(this).parent("div").find(".right_xsxm_box[data-sort='0']").removeClass("active")
							
							if(param.pageTh!="" && $(this).parent("div").attr("data-th")!=param.pageTh){
//								$(this).find(".line3 .ifCheck,.multiSelBox").remove()
								$(this).find(".line3 .ifCheck").remove()
								$(this).removeClass("active")
							}
						}else{
							$(this).parent("div").find(".right_xsxm_box[data-sort='0']").addClass("active")
						}
					}else{
						var html = '<div class="ifCheck" style="float:left;margin-right:3px;"><i class="fa fa-check" style="zoom: 95%;color:'+color+'" aria-hidden="true"></i></div>'
						$(this).find(".line3").prepend(html)
//						$(this).find(".line3").append(html_box)
						$(this).addClass("active")
						$(this).parent("div").find(".right_xsxm_box[data-sort='0']").addClass("active")
					}
					t.retrievePayable();
				})
			}else{
				el.find(".rightXsxmTitle").unbind("dblclick").dblclick(function(){
					$(this).parent("div").parent("div").find(".rightXsxmTitle").removeClass("active")
//					$(this).parent("div").parent("div").find(".rightXsxmTitle").find(".line3 .ifCheck,.multiSelBox").remove()
					$(this).parent("div").parent("div").find(".rightXsxmTitle").find(".line3 .ifCheck,.ifCheckOut").remove()
					$(".span_th").removeClass("mainTh")
					var html = '<div class="ifCheck" style="float:left;margin-right:3px;"><i class="fa fa-check" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
					$(this).find(".line3").prepend(html)
					var html1 = '<div class="ifCheckOut" style="float:left;margin-right:3px;"><i class="fa fa-sign-out" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
					$(this).find(".line3").append(html1)
//					var html_box = '<div class="multiSelBox"  style="width: 45px;height:45px;left:-23px;bottom:-23px;position:absolute;-webkit-transform: rotate(45deg);border: 1px solid #59d245;background: white;"></div>';
//					$(this).find(".line3").append(html_box)
					$(this).find(".span_th").addClass("mainTh")
					$(this).addClass("active")
					var th = $(this).parent("div").attr("data-th")
					
					param.freshBack(th)
					
					t.retrievePayable();
				})
				
				el.find(".rightXsxmTitle").unbind("click").click(function(event){
					if($(this).parent("div").attr("data-th")!=$("#pageTh").text()){
						if($(this).hasClass("active")){
							$(this).removeClass("active")
							$(this).find(".line3 .ifCheck").remove()
							$(this).find(".line3 .ifCheckOut").remove()
						}else{
							var html = '<div class="ifCheck" style="float:left;margin-right:3px;"><i class="fa fa-check" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
							$(this).find(".line3").prepend(html)
							$(this).addClass("active")
						}
					}else{
						if($(this).find(".ifCheckOut").size()>0){
							$(this).find(".ifCheckOut").remove()
						}
					}
					
					t.retrievePayable();
				})
				
				
				$(".xsxmTh_container .rightXsxmTitle").contextMenu('xsxmMenu',{
					bindings:{
						//取消
						'xsxmMenu_cancel': function(){
							t.xsxmMenu_cancel_func();
						},
						//切换
						'xsxmMenu_change': function(t){
							$(t).trigger("dblclick")
						},
						//选择
						'xsxmMenu_check': function(t){
							$(t).trigger("click")
						},
						//全选
						'xsxmMenu_allcheck': function(){
							t.xsxmMenu_allcheck_func();
						},
						//离店
						'xsxmMenu_checkout': function(t){
							if($(t).find(".line3 .ifCheck").size()<=0){
								$(t).trigger("click")
							}else{
								
							}
							$(t).find(".line3 .ifCheckOut").remove()
//							var html = '<span class="xsxm_checkout" style="color:'+param.handpanel_info.tcolor+' ">离</span>';
							var html = '<div class="ifCheckOut" style="float:left;margin-right:3px;"><i class="fa fa-sign-out" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
							$(t).find(".line3").append(html)
						},
						//全部离店
						'xsxmMenu_allcheckout': function(){
							t.xsxmMenu_allcheckout_func();
						},
					},
					onShowMenu: function(e, menu) {
						window.clearTimeout(rightMenuClock)
						
						var _this
						if(e.target.tagName=="DIV"){
							_this = $(e.target)
						}else{
							_this = $(e.target).parent("div")
						}
						
						rightMenuClock = setTimeout(() => {
							$("#jqContextMenu").css("display","none")
						}, 5000);
						
				        return menu;
			      	}
				});
				
				
			}
		},
		xsxmMenu_cancel_func:function(){
			$(".rightXsxmTitle").each(function(key,value){
				if($(this).hasClass("active")){
					$(this).trigger("click")
				}
			})
			
			$(".rightXsxmTitle.active").find(".line3 .ifCheckOut").remove()
			var html = '<div class="ifCheckOut" style="float:left;margin-right:3px;"><i class="fa fa-sign-out" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
			$(".rightXsxmTitle.active").find(".line3").append(html)
		},
		xsxmMenu_allcheck_func:function(){
			$(".rightXsxmTitle").each(function(key,value){
				if(!$(this).hasClass("active")){
					$(this).trigger("click")
				}
			})
		},
		xsxmMenu_allcheckout_func:function(){
			$(".rightXsxmTitle").each(function(key,value){
				if($(this).find(".line3 .ifCheckOut").size()<=0){
					if($(this).find(".line3 .ifCheck").size()<=0){
						$(this).trigger("click")
					}
					
					$(this).find(".line3 .ifCheckOut").remove()
					var html = '<div class="ifCheckOut" style="float:left;margin-right:3px;"><i class="fa fa-sign-out" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
					$(this).find(".line3").append(html)
				}
			})
		},
		initHtml : function(){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var csstext = 	'<style>'+
								'.rightXsxmTitle{cursor: pointer;width:80px;display:flex;flex-direction:column;align-items:center;font-size:16px;background:#ededed;border-bottom: 1px solid #f5f5f5;margin:0px auto;}'+
								'.rightXsxmTitleSpan{word-break:break-all;line-height: 17px;color:#2b8ccc;}'+
								'.right_xsxm_box{cursor: pointer;float: left;border: 1.5px solid #e2d8d8;border-radius: 3px;position: relative;margin:0px 2px 2px 0px;height: auto;padding: 4px 5px;}'+
								'.right_xsxm_box.active{border: 1.5px solid #2b8ccc;}'+
								'.right_xsxm_box_line1,.right_xsxm_box_line2,.right_xsxm_box_line3{height: 100%;float:left;margin-right:10px;}'+
								'.mainTh{border:1px solid white;border-radius: 5px;padding: 0px 2px;}'+
							'</style>';
			$(csstext).appendTo('.row')
			
			
//			var width = (el.width()-20-20)/5
//			var height = (el.height()-20-28)/7
			el.empty()
			var boxHtml = 	'<div class="xsxmTh_container" style="height:100%;width:100%;overflow-y:auto;overflow-x:hidden;"></div>'+
							'<div class="contextMenu" id="xsxmMenu" style="display: none;">'+
							    '<ul class="dropdown-preview dropdown-menu dropdown-info"  style="min-width:100px;">'+
							        '<li id="xsxmMenu_check"><i class="fa fa-check" style="color:#0787f5;margin-left: 10px;margin-right: 10px;" aria-hidden="true"></i><span>选择</span></li>'+   
							        '<li class="divider" style="margin:9px 0px"></li>'+
							        '<li id="xsxmMenu_allcheck"><i class="fa fa-check" style="color:#0787f5;margin-left: 10px;margin-right: 10px;position: relative;" aria-hidden="true">'+
							        	'<i class="fa fa-check" style="color: #00b8ff;position: absolute;left: 4px;top: 1px;" aria-hidden="true"></i>'+
							        '</i><span>全选</span></li>'+   
							        '<li class="divider" style="margin:9px 0px"></li>'+
							        '<li id="xsxmMenu_checkout"><i class="fa fa-sign-out" style="color:#d24545;margin-left: 10px;margin-right: 10px;" aria-hidden="true"></i><span>离店</span></li>'+
							        '<li class="divider" style="margin:9px 0px"></li>'+
							        '<li id="xsxmMenu_allcheckout"><i class="fa fa-sign-out" style="color:#d24545;margin-left: 10px;margin-right: 10px;position: relative;" aria-hidden="true"></i><span>全部离店</span></li>'+
							        '<li class="divider" style="margin:9px 0px"></li>'+
							        '<li id="xsxmMenu_change"><i class="fa fa-exchange" style="color:#59d245;margin-left: 10px;margin-right: 10px;" aria-hidden="true"></i><span>切换</span></li>'+
							        '<li class="divider" style="margin:9px 0px"></li>'+
							        '<li id="xsxmMenu_cancel"><i class="fa fa-times" style="color:#CCC;margin-left: 10px;margin-right: 12px;" aria-hidden="true"></i><span>取消</span></li>'+
							    '</ul>'+        
							'</div>';
			el.append(boxHtml);
			
			$.each(param.brzd_array,function(key,value){
				var handpanel_info = JSON.parse(value.handpanel_info)
				var class_extend = ""
				if(param.pageTh==value.th){
					class_extend = "mainTh"
				}
				var ico_info = JSON.parse(value.ico_info)
				var ico_info_text = ""
					$.each(ico_info,function(key,value){
						if(JSON.stringify(value)!="{}"){
							ico_info_text += getTextStyle(value);
						}
					})
				var th = '<span class="" style="">'+value.th+'</span>';
				var je = '<span class="" style="">'+value.xfje+'</span>';
				if(el.find(".xsxmTh_box[data-no='"+value.no+"']").size()<=0){
					var html = 	'<div class="xsxmTh_box" data-no="'+value.no+'" data-th="'+value.th+'" data-mess="'+encodeURIComponent(JSON.stringify(value))+'" style="display:flex !important;margin-bottom:4px;border-bottom: 1px solid #E8E8E8;">'+
									'<div class="rightXsxmTitle" style="height:60px;width:100px;background:'+handpanel_info.bgcolor+' !important;overflow: hidden;border: 1px solid '+handpanel_info.bgcolor+';">'+
										'<div class="line1" style="width: 100%;height:20px;line-height: 20px;float: left;">'+
											'<span class="span_th '+class_extend+'" style="color:'+handpanel_info.tcolor+' !important;font-size: 13px;">'+th+'</span>'+
											'<small class="text-muted" style="color:'+handpanel_info.tcolor+' !important; font-size:60%;  float:right;">'+
												ico_info_text+
											'</small>'+
										'</div>'+
										'<div class="line2" style="width: 100%;height:20px;line-height: 20px;float: left;text-align: right;">'+
											'<span style="color:'+handpanel_info.tcolor+' !important;font-size: 13px;">'+je+'</span>'+
										'</div>'+
										'<div class="line3" style="width: 100%;height:20px;line-height: 20px;float: left;text-align: right;position:relative;padding-left:0px;">'+
					//						'<span style="color:'+handpanel_info.tcolor+' !important;font-size: 13px;">'+dfje+'</span>'+
										'</div>'+
										
									'</div>'+
									'<div class="xsxmLine clearfix" data-xsxm_no="xsxm_'+value.no+'" style="flex:1;padding-left:2px">'+
									'</div>'+
								'<div>';
					el.find(".xsxmTh_container").append(html)
				}
			})
			$.each(param.xsxm_jdh_array,function(key,value){
//				if(el.find(".xsxmTh_box[data-no='"+value.no+"']").size()<=0){
//					var title  = param.brzd_json[value.ct_brzd_th]
//
//					var handpanel_info = JSON.parse(title.handpanel_info)
//					param.handpanel_info = handpanel_info
//					var th = '<span class="" style="">'+title.th+'</span>';
//					var class_extend = ""
//					if(param.pageTh==title.th){
//						class_extend = "mainTh"
//					}
//					var je = '<span class="" style="">'+title.xfje+'</span>';
//					var dfje = ''
//					if(Number(title.dfje)!=0){
//						dfje = 	'<span class="" style="">('+title.dfje+')</span>';
//					}
//					var ico_info = JSON.parse(title.ico_info)
//					var ico_info_text = ""
//						$.each(ico_info,function(key,value){
//							if(JSON.stringify(value)!="{}"){
//								ico_info_text += getTextStyle(value);
//							}
//						})
//					
//					var html = 	'<div class="xsxmTh_box" data-no="'+value.no+'" data-th="'+value.ct_brzd_th+'" data-mess="'+encodeURIComponent(JSON.stringify(value))+'" style="display:flex !important;margin-bottom:4px;border-bottom: 1px solid #E8E8E8;">'+
//									'<div class="rightXsxmTitle" style="height:60px;width:100px;background:'+handpanel_info.bgcolor+' !important;overflow: hidden;border: 1px solid '+handpanel_info.bgcolor+';">'+
//										'<div class="line1" style="width: 100%;height:20px;line-height: 20px;float: left;">'+
//											'<span class="span_th '+class_extend+'" style="color:'+handpanel_info.tcolor+' !important;font-size: 13px;">'+th+'</span>'+
//											'<small class="text-muted" style="color:'+handpanel_info.tcolor+' !important; font-size:60%;  float:right;">'+
//												ico_info_text+
//											'</small>'+
//										'</div>'+
//										'<div class="line2" style="width: 100%;height:20px;line-height: 20px;float: left;text-align: right;">'+
//											'<span style="color:'+handpanel_info.tcolor+' !important;font-size: 13px;">'+je+'</span>'+
//										'</div>'+
//										'<div class="line3" style="width: 100%;height:20px;line-height: 20px;float: left;text-align: right;position:relative;padding-left:0px;">'+
////											'<span style="color:'+handpanel_info.tcolor+' !important;font-size: 13px;">'+dfje+'</span>'+
//										'</div>'+
//										
//									'</div>'+
//									'<div class="xsxmLine clearfix" data-xsxm_no="xsxm_'+value.no+'" style="flex:1;padding-left:2px">'+
//									'</div>'+
//								'<div>';
//					el.find(".xsxmTh_container").append(html)			
//				}
				if(el.find(".xsxmTh_box[data-no='"+value.no+"']").size()>0){
					var mess_old = JSON.parse(decodeURIComponent(el.find(".xsxmTh_box[data-no='"+value.no+"']").attr("data-mess")))
					var mess_new = JSON.stringify(value)
					el.find(".xsxmTh_box[data-no='"+value.no+"']").attr("data-mess",encodeURIComponent(JSON.stringify($.extend(JSON.parse(mess_new),mess_old))))
				}
				
				var info = JSON.parse(value.info)
				var info_text = ""
				$.each(info,function(key,value){
					if(JSON.stringify(value)!="{}"){
						info_text += getTextStyle(value);
					}
				})
				
				var panel_info =  JSON.parse(value.panel_info)
				var bgcolor = (panel_info['bgcolor']?panel_info['bgcolor']:"white")
				var tcolor = (panel_info['tcolor']?panel_info['tcolor']:"")
				
				
				var xsxmhtml = 	'<div class="right_xsxm_box" data-sort="'+value.sort+'" data-bh="'+value.bh+'" data-xh="'+value.xh+'" data-th="'+value.ct_brzd_th+'"  data-mess="'+encodeURIComponent(JSON.stringify(value))+'" style="background-color:'+bgcolor+';color:'+tcolor+';">'+
									'<div class="right_xsxm_box_line3" style="display: flex;">'+
										info_text+
									'</div>'+
								'</div>';
				$(".xsxmLine[data-xsxm_no='xsxm_"+value.no+"']").append(xsxmhtml)
				
//				var index = $(".xsxmLine[data-xsxm_no='xsxm_"+value.no+"'] div[data-th='"+value.ct_brzd_th+"']").size()
//				$(".xsxmLine[data-xsxm_no='xsxm_"+value.no+"']").find("div[data-xh='"+value.xh+"']").find("span:eq(0)").prepend(index+".")
			})
			
			
			t.retrievePayable();
		},
		//获取选中值
		retrieveActive:function(jsonkey){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var out_array = []
			el.find(".right_xsxm_box.active[data-sort='0']").each(function(){
				var json = JSON.parse(decodeURIComponent($(this).attr("data-mess")))
				if(jsonkey){
					if(json[jsonkey]){
						out_array.push(json[jsonkey])
					}
				}else{
					out_array.push(json)
				}
			})
			return out_array
		},
		//获取选中值
		retrieveBrzdActive:function(jsonkey){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var out_array = []
			el.find(".rightXsxmTitle.active").each(function(){
				var json = JSON.parse(decodeURIComponent($(this).parent("div").attr("data-mess")))
				if(jsonkey){
					if(json[jsonkey]){
						out_array.push(json[jsonkey])
					}
				}else{
					out_array.push(json)
				}
			})
			return out_array
		},
		//获取 选中值
		retrieveCheckoutActive:function(jsonkey){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var out_array = []
			el.find(".rightXsxmTitle .ifCheckOut").each(function(){
				var json = JSON.parse(decodeURIComponent($(this).parents(".xsxmTh_box").attr("data-mess")))
				if(jsonkey){
					if(json[jsonkey]){
						out_array.push(json[jsonkey])
					}
				}else{
					out_array.push(json)
				}
			})
			return out_array
		},
		//获取应付数值
		retrievePayable:function(){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var payTotal = 0
			if(param.multiCheck=="yes"){
				if(el.find(".rightXsxmTitle.active").size()<=0){
					el.find(".right_xsxm_box[data-sort='0']").each(function(){
						var json = JSON.parse(decodeURIComponent($(this).attr("data-mess")))
						payTotal = (Number(payTotal) + Number(json.amount)).toFixed(2)
					})
				}else{
					el.find(".rightXsxmTitle.active").each(function(){
						$(this).parent("div").find(".right_xsxm_box.active[data-sort='0']").each(function(){
							var json = JSON.parse(decodeURIComponent($(this).attr("data-mess")))
							payTotal = (Number(payTotal) + Number(json.amount)).toFixed(2)
						})
					})
				}
			}else{
				var className = ".rightXsxmTitle.active"
				if(el.find(".rightXsxmTitle.active").size()<=0){
					className = ".rightXsxmTitle"
				}else{
					className = ".rightXsxmTitle.active"
				}
				el.find(className).each(function(){
					var json = JSON.parse(decodeURIComponent($(this).parent("div").attr("data-mess")))
					payTotal = (Number(payTotal) + Number(json.xfje)).toFixed(2)
				})
			}
			param.clickBack(payTotal)
		},
		getFilter:function(jsonkey){
			var el = this.el;
			var param = this.param;
			var t = this;
			
			var out_array = []
			var checkClass = ""
			if(el.find(".rightXsxmTitle.active").size()>0){
				checkClass = ".rightXsxmTitle.active"
			}else{
				checkClass = ".rightXsxmTitle"
			}
			el.find(checkClass).each(function(){
				$(this).parent("div").find(".right_xsxm_box[data-sort='0']").each(function(){
					var json = JSON.parse(decodeURIComponent($(this).attr("data-mess")))
					if(jsonkey){
						if(json[jsonkey]){
							out_array.push(json[jsonkey])
						}
					}else{
						out_array.push(json)
					}
				})
			})
			return out_array
		},
		setSelectByXsxm:function(data){
			var el = this.el;
			var param = this.param;
			var t = this;
			$(".right_xsxm_box[data-sort='0'],.rightXsxmTitle,.ifCheck").removeClass("active")
//			$(".ifCheck,.multiSelBox").remove() 
			$(".ifCheck,.mainTh").remove() 
			
			var th = $("#pageTh").text()
			var html = '<div class="ifCheck" style="float:left;margin-right:3px;"><i class="fa fa-check" style="zoom: 95%;color:#59d245" aria-hidden="true"></i></div>'
//			var html_box = '<div class="multiSelBox"  style="width: 45px;height:45px;left:-23px;bottom:-23px;position:absolute;-webkit-transform: rotate(45deg);border: 1px solid #59d245;background: white;"></div>';
			$(".rightXsxmTitle").parent("div[data-th='"+th+"']").find(".line3").prepend(html)
			$(".rightXsxmTitle").parent("div[data-th='"+th+"']").find(".span_th ").addClass("mainTh")
//			$(".rightXsxmTitle").parent("div[data-th='"+th+"']").find(".line3").append(html_box)
			$(".rightXsxmTitle").parent("div[data-th='"+th+"']").find(".rightXsxmTitle").addClass("active") 
					
			$.each(data,function(key,value){
				$(".right_xsxm_box[data-sort='0'][data-xh='"+value+"']").addClass("active") 
				if(!$(".right_xsxm_box[data-sort='0'][data-xh='"+value+"']").parent("div").parent("div").find(".rightXsxmTitle").hasClass("active") ){
					var color = "#59d245"
					if( $(".right_xsxm_box[data-sort='0'][data-xh='"+value+"']").parent("div").parent("div").attr("data-th") != $("#pageTh").text() ){
						color = "#59d245"
					}
					
					$(".right_xsxm_box[data-sort='0'][data-xh='"+value+"']").parent("div").parent("div").find(".rightXsxmTitle").addClass("active")
					var html = '<div class="ifCheck" style="float:left;margin-right:3px;"><i class="fa fa-check" style="zoom: 95%;color:'+color+'" aria-hidden="true"></i></div>'
					$(".right_xsxm_box[data-sort='0'][data-xh='"+value+"']").parent("div").parent("div").find(".rightXsxmTitle").find(".line3").prepend(html)
				}
			})
			t.retrievePayable();
		},
	}
	function getContextPath(){
		var pathName = document.location.pathname;
		var index = pathName.substr(1).indexOf("/");
		var path = pathName.substr(0, index + 1);
		return path;
	}
})(jQuery);